layout.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import Image from "next/image";
  2. import { Inter, Permanent_Marker } from "next/font/google";
  3. import { GeistSans } from "geist/font/sans";
  4. import { GeistMono } from "geist/font/mono";
  5. import { cn } from "@/shared/lib/utils";
  6. import { getServerUrl } from "@/shared/lib/server-url";
  7. import { FB_PIXEL_ID } from "@/shared/lib/facebook/fb-pixel";
  8. import { SiteConfig } from "@/shared/config/site-config";
  9. import { WorkoutSessionsSynchronizer } from "@/features/workout-session/ui/workout-sessions-synchronizer";
  10. import { ThemeSynchronizer } from "@/features/theme/ui/ThemeSynchronizer";
  11. import { Header } from "@/features/layout/Header";
  12. import { Footer } from "@/features/layout/Footer";
  13. import { TailwindIndicator } from "@/components/utils/TailwindIndicator";
  14. import { NextTopLoader } from "@/components/ui/next-top-loader";
  15. import { Providers } from "./providers";
  16. import type { ReactElement } from "react";
  17. import type { Metadata } from "next";
  18. import "@/shared/styles/globals.css";
  19. export const metadata: Metadata = {
  20. title: {
  21. default: SiteConfig.title,
  22. template: `%s | ${SiteConfig.title}`,
  23. },
  24. description: SiteConfig.description,
  25. metadataBase: new URL(getServerUrl()),
  26. robots: {
  27. index: true,
  28. follow: true,
  29. googleBot: {
  30. index: true,
  31. follow: true,
  32. "max-snippet": -1,
  33. "max-image-preview": "large",
  34. "max-video-preview": -1,
  35. },
  36. },
  37. openGraph: {
  38. title: SiteConfig.title,
  39. description: SiteConfig.description,
  40. url: getServerUrl(),
  41. siteName: SiteConfig.title,
  42. images: [
  43. {
  44. url: `${getServerUrl()}/images/default-og-image_fr.png`,
  45. width: 1200,
  46. height: 630,
  47. alt: SiteConfig.title,
  48. },
  49. {
  50. url: `${getServerUrl()}/images/default-og-image_en.png`,
  51. width: 1200,
  52. height: 630,
  53. alt: SiteConfig.title,
  54. },
  55. ],
  56. locale: "fr_FR",
  57. type: "website",
  58. },
  59. twitter: {
  60. card: "summary_large_image",
  61. site: "@workout_cool",
  62. title: SiteConfig.title,
  63. description: SiteConfig.description,
  64. images: [`${getServerUrl()}/images/default-og-image_fr.png`],
  65. },
  66. alternates: {
  67. canonical: "https://www.workout.cool",
  68. languages: {
  69. fr: "https://www.workout.cool/fr",
  70. en: "https://www.workout.cool/en",
  71. },
  72. },
  73. authors: [{ name: "Workout Cool", url: "https://www.workout.cool" }],
  74. icons: {
  75. icon: [
  76. { url: "/images/favicon-32x32.png", sizes: "32x32", type: "image/png" },
  77. { url: "/images/favicon-16x16.png", sizes: "16x16", type: "image/png" },
  78. { url: "/images/favicon.ico", type: "image/x-icon" },
  79. ],
  80. apple: "/apple-touch-icon.png",
  81. },
  82. };
  83. const inter = Inter({
  84. subsets: ["latin"],
  85. variable: "--font-inter",
  86. display: "swap",
  87. });
  88. const permanentMarker = Permanent_Marker({
  89. weight: "400",
  90. subsets: ["latin"],
  91. variable: "--font-permanent-marker",
  92. display: "swap",
  93. });
  94. export const preferredRegion = ["fra1", "sfo1", "iad1"];
  95. interface RootLayoutProps {
  96. params: Promise<{ locale: string }>;
  97. children: ReactElement;
  98. }
  99. export default async function RootLayout({ params, children }: RootLayoutProps) {
  100. const { locale } = await params;
  101. return (
  102. <>
  103. <html className="h-full" dir="ltr" lang={locale} suppressHydrationWarning>
  104. <head>
  105. <meta charSet="UTF-8" />
  106. <meta content="width=device-width, initial-scale=1, maximum-scale=1 viewport-fit=cover" name="viewport" />
  107. {/* eslint-disable-next-line @next/next/no-page-custom-font */}
  108. <link as="style" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="preload" />
  109. {/* Alternate hreflang for i18n */}
  110. <link href="https://www.workout.cool/fr" hrefLang="fr" rel="alternate" />
  111. <link href="https://www.workout.cool/en" hrefLang="en" rel="alternate" />
  112. {/* Balise theme-color unique, synchronisée dynamiquement */}
  113. <meta content="#f3f4f6" name="theme-color" />
  114. {/* TODO: maybe add some ads ? */}
  115. <noscript>
  116. <Image
  117. alt="Facebook Pixel"
  118. height="1"
  119. src={`https://www.facebook.com/tr?id=${FB_PIXEL_ID}&ev=PageView&noscript=1`}
  120. style={{ display: "none" }}
  121. width="1"
  122. />
  123. </noscript>
  124. </head>
  125. <body
  126. className={cn(
  127. "flex items-center justify-center min-h-screen w-full p-8 max-sm:p-0 max-sm:min-h-full bg-base-200 dark:bg-[#18181b] dark:text-gray-200 antialiased",
  128. "bg-hero-light dark:bg-hero-dark",
  129. GeistMono.variable,
  130. GeistSans.variable,
  131. inter.variable,
  132. permanentMarker.variable,
  133. )}
  134. suppressHydrationWarning
  135. >
  136. <Providers locale={locale}>
  137. <WorkoutSessionsSynchronizer />
  138. <ThemeSynchronizer />
  139. <NextTopLoader color="#FF5722" delay={100} showSpinner={false} />
  140. {/* Main Card Container */}
  141. <div className="card w-full max-w-3xl min-h-[500px] max-h-[90vh] h-[80vh] bg-white dark:bg-[#232324] shadow-xl border border-base-200 dark:border-slate-700 flex flex-col justify-between overflow-hidden max-sm:rounded-none max-sm:h-full rounded-lg">
  142. <Header />
  143. <div className="flex-1 overflow-auto flex flex-col">{children}</div>
  144. <Footer />
  145. </div>
  146. <TailwindIndicator />
  147. </Providers>
  148. </body>
  149. </html>
  150. </>
  151. );
  152. }